#include <func.h>
#include <mysql/mysql.h>

int main(void)
{
    // 初始化连接
    MYSQL* mysql = mysql_init(NULL);

    // 建立连接
    mysql_real_connect(mysql, "localhost", "root", "123456", "test", 0, NULL, 0);

    // 增
    mysql_query(mysql, "insert into student values (11, '云中鹤', 67, 78, 94, '2345-12-12', '襄阳')");

    // 删
    //mysql_query(mysql, "delete from student where id = 11");

    // 改
   mysql_query(mysql, "update student set jiguan = '并州' where id = 11");

    // 查
   mysql_query(mysql, "select * from student");
   MYSQL_RES* result = mysql_store_result(mysql);
   unsigned int fields = mysql_num_fields(result); 

   MYSQL_ROW ROW;
   while(ROW = mysql_fetch_row(result))
   { 
       for(unsigned int i = 0; i < fields; ++i)
           printf("%s\t", ROW[i]);
       printf("\n");
   }
   // 释放连接
   mysql_free_result(result);

    return 0;
}

